package net.xxcxcxcx.xc_enhancedmob.skills.basics.individual.common;

import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.world.explosion.Explosion;
import net.xxcxcxcx.xc_enhancedmob.config.skill.SkillConfig;
import net.xxcxcxcx.xc_enhancedmob.skills.BaseSkill;

public class SelfdetonationSkill extends BaseSkill {

    public SelfdetonationSkill(int level) {
        super(level);
    }

    public SelfdetonationSkill(NbtCompound nbtCompound) {
        super(nbtCompound);
    }

    public SelfdetonationSkill() {
    }

    @Override
    public SkillConfig getDefaultConfig() {
        SkillConfig skillConfig = super.getDefaultConfig();
        skillConfig.setMessage(getConfigMessage(skillConfig));
        return skillConfig;
    }

    @Override
    public String getConfigMessage(SkillConfig skillConfig) {
        if (skillConfig == null) return super.getConfigMessage(null);
        return String.format("自爆技能，死亡时候产生爆炸（level级）效果。");
    }

    @Override
    public boolean onDeath(LivingEntity attacker, MobEntity target, DamageSource source, boolean ismob, boolean remote) {
        target.world.createExplosion(target, DamageSource.mob(target), null, target.getX(), target.getY(), target.getZ(), getSkillLevel(), true, Explosion.DestructionType.NONE);
        return true;
    }
}
